<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>{BEESCRM:$title}</title>
    <meta name="description" content="">
    <meta name="HandheldFriendly" content="True">
    <meta name="MobileOptimized" content="320">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui, user-scalable=no">
    <meta http-equiv="cleartype" content="on">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/assets/complaint/css/style.css">
    <link rel="stylesheet" href="/assets/complaint/css/layer.css">
</head>
<body>
<div class="wrapper">
    <div class="header header2 text-center">
        <a href="javascript:history.go(-1);" class="iconfont icon-zuo left"></a>
        <div class="font-16">投诉</div>
    </div>
    <form id="complaintform" action="/Complaint/Common/complaint/irs_id/{BEESCRM:$irs_id}">
        <input id="employee_id" name="employee_id" value="{BEESCRM:$employee_id}" type="hidden" style="display: none">
        <input id="anonymity" name="anonymity" value="" type="hidden" style="display: none">
        <input id="employee_restaurant_id" name="employee_restaurant_id" value="{BEESCRM:$employee_restaurant_id}" type="hidden" style="display: none">
        <div class="content padding-12">
            <div class="list">
                <textarea class="font-12 gray2" name="content" id="content" cols="30" rows="10"
                          placeholder="请输入投诉内容"></textarea>
            </div>
            <div class="list">
                <div class="load-img text-center">
                    <div class="img" id="show_img">
                        <div class="delete iconfont icon-shanchu hide" id="delete"></div>
                    </div>
                    <div class="load ">+</div>
                </div>
                <input type="file" class="file hide" onchange="showPreview(this)" name="inputfile" id="picture">
            </div>
            <div class="list text-right">
                <div class="anonymity">
                    <span  class="iconfont icon-xuanzhong1 margin-r8 gray3" id="niming" name="anonymity"  type="radio" data-value="1" ></span>匿名

                </div>
            </div>
        </div>
        <a href="#" class="btn text-center font-16">提交评论</a>
       <!-- <button type="submit" id='sub' class="btn btn-success pull-right">提交评论</button>-->
    </form>
</div>
<include file="Common:load"/>
</body>
<script src="/assets/complaint/js/public.js"></script>
<script src="/assets/complaint/js/layer.js"></script>
<script src="/assets/complaint/js/jquery-2.1.0.min.js"></script>
<script>
    $('.load').click(function () {
        $('.file').click();
    });


    function showPreview(source) {
        var file = source.files[0];
        if (window.FileReader) {  //当浏览器支持fileReader
            var fr = new FileReader();
            fr.onloadend = function (e) {
                var img = document.createElement("img");
                img.onerror = null;
                img.src = e.target.result;
                img.alt = '';
                img.id = 'pic';
                //$("#portrait").attr('src', e.target.result);
                $("#show_img").append(img);
                document.getElementById("delete").style.display = "block";

            };
            fr.readAsDataURL(file);
        }
    }

    $('#delete').click(function () {
        document.getElementById("picture").value = "";
        $('#pic').remove();
        document.getElementById("delete").style.display = "none";
    });

    /*   $(".img").mousedown(function() {
     timeout = setTimeout(function() {
     $(".delete").removeClass('hide');
     }, 2000);
     });
     $(".img").mouseup(function() {
     clearTimeout(timeout);
     $(".delete").removeClass('hide');
     });*/



    $('.btn').click(function () {
        var content = $('#content').val();
        if (!content) {
            fm.alert('请输入评论内容');
            return;
        }
        /*if($('.iconfont').hasClass('gray3')){
            var content_type=1;
        }
        if($('.iconfont').hasClass('green')){
            var content_type=0;
        }*/
        var anonymity = $('#niming').val();
        $('#anonymity').val(anonymity)
        var form = new  FormData(document.getElementById("complaintform"));

        $.ajax({
            data:form,
            method: 'post',
            processData:false,
            contentType:false,
            dataType: 'json',
            url: '/Complaint/Common/toComplaint/irs_id/{BEESCRM:$irs_id}',
            success: function (result) {
                if (result.status == 'S') {
                    fm.alert('评论成功');
                    window.location.href="/Complaint/Common/apartment/restaurant_id/{BEESCRM:$employee_restaurant_id}/irs_id/{BEESCRM:$irs_id}";
                } else {
                    fm.alert('评论失败');
                    reload1();
                }
            }
        })
    });
    $('#niming').click(function () {
        if($('.iconfont').hasClass('gray3')){
            $('.iconfont').removeClass('gray3');
            $('.iconfont').addClass('green');
            $('.iconfont').val('0');



        }else{
            $('.iconfont').val('1');
            $('.iconfont').removeClass('green');
            $('.iconfont').addClass('gray3');
        }
    })
    function reload1(){
        setTimeout('location.reload()', 2000);
    }
</script>
</html>